Device and text representation method applied to sentence embedding

ABSTRACT

The invention discloses a device and text representation method applied to sentence embedding, which has determining a parent word and a child words set corresponding to the parent word, obtaining an hidden interaction state of parent word based on the hidden interaction state of all child words; obtaining parent word sequence corresponding to the parent word and obtaining hidden state sequence corresponding to the hidden state of parent word; obtaining the interaction representation sequence of each parent word and other parent word based on the hidden state sequence, generating sentence embeddings. The invention proposes to realize sentence embeddings through a two-level interaction representation. The two-level interaction representation is local interaction representation and a global interaction representation respectively, and combines the two-level representation to generate a hybrid interaction representation, which can improve the accuracy and efficiency of sentence embeddings and be significantly better than the Tree-LSTM model in terms of accuracy.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application claims priority to Chinese Patent Application No.201811361939.5 with a filing date of Nov. 15, 2018. The content of theaforementioned application, including any intervening amendmentsthereto, are incorporated herein by reference.

BACKGROUND OF THE INVENTION Technical Field

The invention relates to the field of artificial intelligencetechnologies, more particularly to a device, a storage medium and a textrepresentation method applied to sentence embedding.

Background Art

Sentence embedding maps text space to real-valued vectors or matrices,which plays an important role in machine understanding of textrepresentation. Its applications include sentiment classification,question-answering systems and text summaries. The model on sentenceembedding can be classified into the following three categories, namely,statistical embedded model, serialization embedded model and structuredembedding model. Statistical embedded models are estimated based onstatistical indicators, such as the frequency of co-occurring words, theco-occurrence word versus frequency and the weight of words in differenttexts (in the TF-IDF model). The serialization embedded model reliesmainly on the neural network structure to learn text representation,based on a single layer of hidden layers, which is a convolutionalneural network or a recurrent neural network (RNN). The structuredembedding model considers the syntactic structure to reflect thesemantics of the text, such as the recursive neural network and thelong-short memory network (Tree-LSTM) of the tree structure.

The current sentence embedding model has achieved good results in textclassification tasks. However, in the existing embedded model, theprocess of generating sentence embedding usually follows one-way action.That is to say, the representation generated by the previous textdetermines the representation of the next text, which is limited by theone-way effect, causing partial semantic loss.

SUMMARY OF THE INVENTION

The purpose of the invention is to provide a device, a storage mediumand a text representation method applied to sentence embedding toimprove the accuracy and efficiency of sentence embeddings.

According to one aspect of the invention, the invention provides a textrepresentation method applied to sentence embedding, comprising:obtaining a file to be processed, extracting a sentence from the file;wherein the file includes a text file and a webpage file; obtaining nparent word corresponding to n words in the sentence; determining theparent word and the child words set C(p) corresponding to the parentword, setting hidden states h_(k) and memory cells c_(k) for each childwords in the C(p), wherein k∈{1, 2, . . . ,|C(p)|}, |C(p)| is the numberof child words in the C(p); obtaining a hidden interaction state {tildeover (h)}_(p) of the parent word based on a hidden interaction state ofall child words in the C(p); inputting the {tilde over (h)}_(p) and theparent word into the LSTM cell to obtain the memory cells and hiddenstates of the parent word; obtaining a sequence of the parent word {x₁,x₂, . . . , x_(n)} corresponding to then parent word and obtaining ahidden state sequence {h₁, h₂, . . . , h_(n)} corresponding to the {x₁,x₂, . . . , x_(n)} based on the hidden state of the parent word;obtaining the interaction representation sequence {r₁, r₂, . . . ,r_(n)} of each parent word and other parent word in the {x₁, x₂, . . . ,x_(n)} based on {h₁, h₂, . . . , h_(n)}, generating sentence embeddingsbased on the {r₁, r₂, . . . , r_(n)}.

Optionally, the memory cells and hidden states of the parent wordcomprises: the parent word x_(p) is converted into a hiddenrepresentation h_(p) =tanh(W^((h))x_(p)+b^(h)); wherein W^((h)) andb^(h) are the weight matrix and the bias term, respectively; connectingthe parent word x_(p) and the k^(th) child words corresponding to theparent word x_(p), obtaining α_(k)=h_(p) W_(α)h_(k), wherein α_(k) is aconnective representation of both h_(p) and the hidden state h_(k),W_(α) is the connective matrix to be learned;

calculating the word weight

$\lambda_{k} = \frac{\exp\left( \alpha_{k} \right)}{\sum_{i = 1}^{{C{(p)}}}{\exp\;\left( \alpha_{i} \right)}}$of the k^(th) child words in the parent word x_(p);

obtaining the hidden interaction state

${\overset{\sim}{h}}_{p} = {\sum\limits_{i \in {C{(j)}}}\;{\lambda_{i}h_{i}}}$that relates to all child states of the parent word x_(p);

inputting the {tilde over (h)}_(p) and the parent word x_(p) into theLSTM cell, obtaining the memory cells and hidden states of the parentword x_(p).

Optionally, inputting the {tilde over (h)}_(p) and the parent word x_(p)into the LSTM cell, obtaining the memory cells and hidden states of theparent word x_(p) comprises: using the hidden interaction state {tildeover (h)}_(p) and the parent word x_(p) as the input to the LSTM cell toget:i _(p)=σ(U ^((i)) x _(p) +W ^((i)) {tilde over (h)} _(p) +b ^((i)));o _(p)=σ(U ^((o)) x _(p) +W ^((o)) {tilde over (h)} _(p) +b ^((o)));u _(p)=tanh(U ^((u)) x _(p) +W ^((u)) {tilde over (h)} _(p) +b ^((u)));f _(kp)=σ(U ^((f)) x _(p) +W ^((f)) h _(k) +b ^((f)));

wherein i_(p), o_(p) and f_(kp) are the input gate, the output gate andthe forget gate, respectively; u_(p) is the candidate hidden state ofx_(p); the corresponding weight matrix of x_(p) are U^((i)), U^((o)),U^((u)), and U^((f)), the corresponding weight matrix of {tilde over(h)}_(p) or h_(k) are W^((i)), W^((o)), W^((u)) and W^((f)), the biasterms are b^((i)), b^((o)), b^((u)) and b^((f));

obtaining the memory cell of the parent word x_(p), the memory cell isrepresented as:

${c_{p} = {{i_{p} \odot u_{p}} + {\sum\limits_{k = 1}^{{C{(p)}}}\;{f_{kp} \odot c_{k}}}}};$

obtaining the hidden state of the parent word x_(p), the hidden state isrepresented as:h _(p) =o _(p)⊙ tanh(c _(p)).

Optionally, based on the {r₁, r₂, . . . , r_(n)} generating sentenceembeddings comprises: obtaining the connective representation sequence{α_(g1), α_(g2), . . . , α_(gn)} between the word x_(g) in the {x₁, x₂,. . . , x_(n)} and other words;

calculating the interaction weight of word x_(k) and word x_(g) in the{x₁, x₂, . . . , x_(n)}, get:

${\lambda_{g\; k} = \frac{\exp\;\left( \alpha_{gk} \right)}{\sum_{i = 1}^{n}{\exp\left( \alpha_{gi} \right)}}};$

the interaction representation of x_(g) in {x₁, x₂, . . . , x_(n)} isrepresented as:

${r_{g} = {\sum\limits_{i = 1}^{n}\;{\lambda_{gi}h_{i}}}};$

enumerating all the words in the {x₁, x₂, . . . , x_(n)}, obtaining theinteraction representation sequence {r₁, r₂, . . . , r_(n)} of {x₁, x₂,. . . , x_(n)}, generating the sentence embeddings s=max{r₁, r₂, . . . ,r_(n)}.

Optionally, obtaining the predicted label corresponding to the sentenceembeddings s:ŝ=arg max p(

|s);

wherein ŝ∈

,

is the class label set; p(

|s)=softmax(W^((s))s+b^((s))); W^((s)) and b^((s)) are the reshapematrix and the bias term, respectively;

setting the loss function:

${L = {{\frac{1}{n}{\sum\limits_{i = 1}^{n}\;{\log\;{p\left( {{\overset{\sim}{w}}_{i}❘h_{i}} \right)}}}} - {\log\;{p\left( {\overset{\sim}{s}❘s} \right)}}}};$

wherein h_(i) is the hidden state, {tilde over (w)}_(i) is the trueclass label of word x_(i), {tilde over (s)} is the true class label ofsentence embeddings s; evaluating the quality of the sentence embeddingss based on the loss function.

According to a second aspect of the invention, the invention provides atext representation device applied to sentence embedding, comprising: aword extraction module, configured to obtain a file to be processed andextract a sentence from the file; wherein the file includes: a textfile, a webpage file; obtaining n parent word corresponding to n wordsin the sentence; a child word processing module, configured to determinethe parent word and a child word set C(p) corresponding to the parentword, setting hidden states h_(k) and memory cells c_(k) for each childwords in the C(p), wherein k∈{1, 2, . . . ,|C(p)|}; a parent wordprocessing module, configured to obtain hidden interaction states {tildeover (h)}_(p) of the parent word based on the hidden interaction statesof all child words in the C(p); inputting the {tilde over (h)}_(p) andthe parent word into the LSTM cell to obtain the memory cells and hiddenstates of parent word; a hidden state processing module, configured toobtain a sequence {x₁, x₂, . . . , x_(n)} of parent word correspondingto n parent word as well as obtain a hidden state sequence {h₁, h₂, . .. , h_(n)} corresponding to the {x₁, x₂, . . . , x_(n)} based on thehidden state of parent word; a sentence embedding processing module,configured to obtain a interaction representation sequence {r₁, r₂, . .. , r_(n)} of each parent words and other parent words in {x₁, x₂, . . ., x_(n)} based on the {h₁, h₂, . . . , h_(n)}, generating sentenceembeddings based on the {r₁, r₂, . . . , r_(n)}.

Optionally, the parent word processing module comprises: a hiddenrepresentation unit, configured to convert the parent word x_(p) into ahidden representation h_(p) =tanh(W^((h))x_(p)+b^(h)); wherein, W^((h))and b^(h) are the weight matrix and the bias term, respectively; aconnective processing unit, configured to connect the k^(th) child wordscorresponding to the parent word x_(p) and the parent word x_(p),obtaining α_(k)=h_(p) W_(α)h_(k), wherein α_(k) is the connectiverepresentation of h_(p) and h_(k), W_(α) is a connective matrix; ahidden state extracting unit, configured to calculate the word weight

$\lambda_{k} = \frac{\exp\left( \alpha_{k} \right)}{\sum_{i = 1}^{{C{(p)}}}{\exp\left( \alpha_{i} \right)}}$of the k^(th) child words of the parent word x_(p); obtaining a hiddeninteraction state

${\overset{\sim}{h}}_{p} = {\sum\limits_{i \in {C{(j)}}}\;{\lambda_{i}h_{i}}}$of the parent word x_(p); inputting the {tilde over (h)}_(p) and theparent word x_(p) into the LSTM cell to obtain the memory cells andhidden states of the parent word x_(p).

Optionally, the hidden state processing module, configured to use thehidden interaction state {tilde over (h)}_(p) and the parent word x_(p)as the input to the LSTM cell to get:i _(p)=σ(U ^((i)) x _(p) +W ^((i)) {tilde over (h)} _(p) +b ^((i)));o _(p)=σ(U ^((o)) x _(p) +W ^((o)) {tilde over (h)} _(p) +b ^((o)));u _(p)=tanh(U ^((u)) x _(p) +W ^((u)) {tilde over (h)} _(p) +b ^((u)));f _(kp)=σ(U ^((f)) x _(p) +W ^((f)) h _(k) +b ^((f)));

wherein i_(p), o_(p) and f_(kp) are the input gate, output gate andforget gate, respectively; u_(p) is the candidate hidden state of x_(p);the corresponding weight matrix of x_(p) are U^((i)), U^((o)), U^((u))and U^((f)), the corresponding weight matrix of {tilde over (h)}_(p) orh_(k) are W^((i)), W^((o)), W^((u)) and W^((f)), the bias terms areb^((i)), b^((o)), b^((u)) and b^((f));

the hidden state processing module, configured to obtain the memory cellof the parent word x_(p), the memory cell is represented as:

${c_{p} = {{i_{p} \odot u_{p}} + {\sum\limits_{k = 1}^{{C{(p)}}}\;{f_{kp} \odot c_{k}}}}};$

the hidden state processing module, configured to obtain the hiddenstate of the parent word x_(p), the hidden state is represented as:h _(p) =o _(p)⊙ tanh(c _(p)).

Optionally, the sentence embedding processing module, configured toobtain the connective representation sequence {α_(g1), α_(g2), . . . ,α_(gn)} between the word x_(g) in the {x₁, x₂, . . . , x_(n)} and otherwords; calculating the interaction weight of word x_(k) and word x_(g)in the {x₁, x₂, . . . , x_(n)}, get:

${\lambda_{gk} = \frac{\exp\left( \alpha_{gk} \right)}{\sum_{i = 1}^{n}{\exp\left( \alpha_{gi} \right)}}};$

the sentence embedding processing module, configured to obtain theinteraction representation of x_(g) in {x₁, x₂, . . . , x_(n)}, whichcan be represented as:

${r_{g} = {\sum\limits_{i = 1}^{n}\;{\lambda_{gi}h_{i}}}};$

the sentence embedding processing module, configured to enumerate allthe words in the {x₁, x₂, . . . , x_(n)}, obtaining the interactionrepresentation sequence {r₁, r₂, . . . , r_(n)} of the {x₁, x₂, . . . ,x_(n)}, generating the sentence embeddings s=max{r₁, r₂, . . . , r_(n)}.

Optionally, a quality evaluation module, configured to obtain thepredicted label corresponding to the sentence embeddings s:ŝ=arg max p(

|s);

wherein ŝ∈

,

is the class label set; p(

|s)=softmax(W^((s))s+b^((s))); W^((s)) and b^((s)) are the reshapematrix and the bias term, respectively; the quality evaluation module,configured to set the loss function:

${L = {{{- \frac{1}{n}}{\sum\limits_{i = 1}^{n}\;{\log\;{p\left( {{\overset{\sim}{w}}_{i}❘h_{i}} \right)}}}} - {\log\;{p\left( {\overset{\sim}{s}❘s} \right)}}}};$

wherein h_(i) is the hidden state, {tilde over (w)}_(i) is the trueclass label of word x_(i), {tilde over (s)} is the true class label ofsentence embeddings s; evaluating the quality of the sentence embeddingss based on the loss function.

According to a third aspect of the invention, the invention provides atext representation device applied to sentence embedding, comprising: amemorizer; a processor coupled to the memorizer; the processor isconfigured to perform the aforementioned method based on instructionsstored in the memorizer.

According to a fourth aspect of the invention, the invention provides acomputer readable storage medium, storing computer program instructions,implements the steps of the aforementioned method when the instructionsare executed by the processor.

The invention proposes to realize sentence embeddings through atwo-level interaction representation. The two-level interactionrepresentation is a local interaction representation (LIR) and a globalinteraction representation (GIR), respectively. The invention combinesthe two-level representation to generate a hybrid interactionrepresentation (HIR), which can improve the accuracy and efficiency ofsentence embeddings and be significantly better than the Tree-LSTM modelin terms of accuracy.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a schematic flow chart of an embodiment of a textrepresentation method applied to sentence embedding according to theinvention;

FIG. 2A is a schematic diagram illustrating the relationship between aparent word and a child word in an embodiment of a text representationmethod applied to sentence embedding according to the invention;

FIG. 2B is a schematic diagram predicting five-class classification taskin an embodiment of a text representation method applied to sentenceembedding according to the invention;

FIG. 2C is a schematic diagram predicting two-class classification taskin an embodiment of a text representation method applied to sentenceembedding according to the invention;

FIG. 3 is a block diagram illustrating an embodiment of a textrepresentation device applied to sentence embedding according to theinvention;

FIG. 4 is a block diagram illustrating a parent word processing modulein an embodiment of a text representation device applied to sentenceembedding according to the invention;

FIG. 5 is a block diagram illustrating another embodiment of a textrepresentation device applied to sentence embedding according to theinvention.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

The embodiments of the invention can be applied to computersystems/servers, being able to operate with general-use or special-usecomputing system environments or configurations. The embodiments is ableto be applied to computing systems, computing environments, and/orconfigurations suitable for using with a computer system/server,including but not limited to: a smartphone, a personal computer system,a server computer system, a thin client, a thick client, a handheld or alaptop devices, microprocessor-based systems, set-top boxes,programmable consumer electronics, network personal computers, smallcomputer systems, large computer systems and distributed cloud computingtechnology environments including any of the above systems, etc.

The computer system/server can be described in the general context ofcomputer system executable instructions (such as program modules) beingexecuted by a computer system. Generally, program modules includeroutines, programs, target programs, components, logic and datastructures, etc. They perform particular tasks or implement particularabstract data types. The computer system/server can be implemented in adistributed cloud computing environment where tasks are performed byremote processing devices that are linked through a communicationnetwork. In a distributed cloud computing environment, program modulescan be located on a local or remote computing system storage mediumincluding storage devices.

FIG. 1 is a schematic flow chart of an embodiment of a textrepresentation method applied to sentence embedding according to theinvention. As illustrated in FIG. 1:

Step 101, obtaining n parent word corresponding to n words in thesentence.

obtaining a file to be processed, extracting a sentence from the file,analyzing and processing the sentence; wherein the file includes a textfile, a webpage file and so on. For instance, the back-end system of thee-commerce website obtains an evaluation document about electronicproducts. In the evaluation document, there are different customers'comments on the electronic products. The sentences related to thecomments are extracted from the evaluation document based on theextraction rules, processing the sentences correspondingly.

Step 102, determining the parent word, and the child words set C(p)corresponding to the parent word, setting hidden states h_(k) and memorycells c_(k) for each child words in the C(p), wherein k∈{1, 2, . . .,|C(p)|}.

For example, for a sentence ‘a dog crossing a ditch’, the sentence isbased on a grammatical dependency, the parent word is ‘crossed’ and thechild word set is ‘a dog, a ditch’. Hidden states h_(k) and memory cellsc_(k) are inherent components of recurrent neural networks. The hiddenstate is used to record the state representation in the network at thecurrent time, while the memory cell is used to record the stateinformation of the network from the beginning to the present.

Step 103, obtaining a hidden interaction state {tilde over (h)}_(p) ofthe parent word based on a hidden interaction state of all child wordsin the C(p). The hidden state and the hidden interaction state aredifferent concepts. The hidden state is inherent to the RNN neuralnetwork, while the hidden interaction state is a hidden staterepresentation obtained by the interaction between the parent word andthe child words.

Step 104, inputting {tilde over (h)}_(p) the and the parent word intothe LSTM cell to obtain the memory cells and hidden states of the parentword;

Step 105, obtaining a sequence of the parent word {x₁, x₂, . . . ,x_(n)} corresponding to the n parent word and obtaining a hidden statesequence {h₁, h₂, . . . , h_(n)} corresponding to the {x₁, x₂, . . . ,x_(n)} based on the hidden state of the parent word.

Step 106, obtaining the interaction representation sequence {r₁, r₂, . .. , r_(n)} of each parent word and other parent word in the {x₁, x₂, . .. , x_(n)} based on {h₁, h₂, . . . , h_(n)}, generating sentenceembeddings based on the {r₁, r₂, . . . , r_(n)}.

The sentence embedding can help machine understand the text. Thesemantics of the text is the product of the mutual influence of thewords in the text. The subsequent words also contribute to the semanticsof the previous words. The embodiment introduces the concept ofinteraction, proposing a two-level interaction representation applied tosentence embedding, namely a local interaction representation and aglobal interaction representation. Combining the two interactionrepresentations provides a hybrid interaction representation. Forexample, a local interaction representation (LIR) and a globalinteraction representation (GIR) generates a hybrid interactionrepresentation (HIR).

Apply a softmax function on a sequence of connective representations{α₁, α₂, . . . , α_(|C(p)|)} to get the weight λ_(k). Calculate the wordweight

$\lambda_{k} = \frac{\exp\left( \alpha_{k} \right)}{\sum_{i = 1}^{{C{(p)}}}{\exp\left( \alpha_{i} \right)}}$of the k^(th) child words in the parent word x_(p). Obtain the hiddeninteraction state

${\overset{\sim}{h}}_{p} = {\sum\limits_{i \in {C{(j)}}}\;{\lambda_{i}h_{i}}}$that relates to all child states of the parent word x_(p); in the actionchild words→parent word, input the {tilde over (h)}_(p) and the parentword into the LSTM cell to obtain the memory cells and hidden states ofthe parent word x_(p). LSTM (Long Short-Term Memory) is a long-term andshort-term memory network. It is a time recurrent neural networksuitable for processing and predicting important events with relativelylong intervals and delays in time series.

Use the hidden interaction state {tilde over (h)}_(p) and the parentword x_(p) as the input to the LSTM cell to get:i _(p)=σ(U ^((i)) x _(p) +W ^((i)) {tilde over (h)} _(p) +b ^((i)));o _(p)=σ(U ^((o)) x _(p) +W ^((o)) {tilde over (h)} _(p) +b ^((o)));u _(p)=tanh(U ^((u)) x _(p) +W ^((u)) {tilde over (h)} _(p) +b ^((u)));f _(kp)=σ(U ^((f)) x _(p) +W ^((f)) h _(k) +b ^((f)));

wherein i_(p), o_(p) and f_(kp) are the input gate, the output gate andthe forget gate, respectively; u_(p) is the candidate hidden state ofx_(p); the corresponding weight matrix of x_(p) are U^((i)), U^((o)),U^((u)) and U^((f)), the corresponding weight matrix of {tilde over(h)}_(p) or h_(k) are W^((i)), W^((o)), W^((u)) and W^((f)), the biasterms are b^((i)), b^((o)), b^((u)) and b^((f)).

Obtain the memory cell of the parent word x_(p), the memory cell isrepresented as:

${c_{p} = {{i_{p} \odot u_{p}} + {\sum\limits_{k = 1}^{{C{(p)}}}\;{f_{kp} \odot c_{k}}}}};$

obtain the hidden state of the parent word x_(p), the hidden state isrepresented as:h _(p) =o _(p)⊙ tanh(c _(p));

wherein ⊙ is the element multiplication, while c_(k) is the memory cellsof a child word.

For example, supposing there is a synthetic parse tree, wherein x_(l)represents a left child word and x_(r) represents a right child word ofthe parent word x_(p). The parent word x_(p) is a non-terminating word(i.e. x_(p) is a zero vector), using x_(l) and x_(r) as controllersinstead of x_(p). Therefore, based on the above formula, the hiddeninteraction state {tilde over (h)}_(l) and {tilde over (h)}_(r) can beobtained separately according to the x_(l) and the x_(r). Connect the{tilde over (h)}_(l) and the {tilde over (h)}_(r) to represent thehidden interaction state representation of the parent word, which is{tilde over (h)}_(p)=[{tilde over (h)}_(l):{tilde over (h)}_(r)].According to the above formula, it is able to obtain the memory cellsc_(p) and hidden states h_(p) of the parent word x_(p). In the localinteraction representation of the child word→parent word, the parentword contains all the information of child words. Therefore, the hiddenstate of this parent word can be embedded as a sentence.

In one embodiment, the GIR employs an enumeration-based strategy toutilize the attention mechanism for all words in a sentence. Afterapplying the Tree-LSTM module to n words in a sentence, it is able toobtain the hidden representation {h¹, h₂, . . . , h_(n)} correspondingto the word sequence {x₁, x₂, . . . , x_(n),}. Tree-LSTM is similar toRNN. After inputting the word sequence {x₁, x₂, . . . , x_(n)} into thenetwork in time series, it correspondingly obtains the hidden staterepresentation of each moment.

In order to represent the interaction of word x_(g) with the other wordsin one sentence, the word x_(g) can be recognized as a semantic weightscontroller in the {x₁, x₂, . . . , x_(n)} besides word x_(g). A commonconnection is applied to connect word x_(g) to the other words, i.e.α_(gk)=h_(g)W_(α)h_(k), wherein α_(gk) is the connective representationof h_(g) and h_(k) (g, k∈(1, 2, . . . , n)). It is able to obtain allthe connective representation {α_(g1), α_(g2), . . . , α_(gn)} betweenword x_(g) and the other words.

The softmax function maps the original output to the probability spaceof (0, 1), while the sum of these values equals to 1. Supposing there isan array V, Vi represents the i-th element in V, then the softmax valueof this element is:

$S_{i} = {\frac{e^{V_{i}}}{\sum_{j}e^{V_{j}}}.}$

Apply the softmax function to connective representation sequence tocalculate the weight, calculating the interaction weight of word x_(k)and word x_(g) in the {x₁, x₂, . . . , x_(n)}, get:

${\lambda_{gk} = \frac{\exp\left( \alpha_{gk} \right)}{\sum_{i = 1}^{n}{\exp\left( \alpha_{gi} \right)}}};$

wherein λ_(gk) is the interaction weight of word x_(k) and word x_(g) inthe {x₁, x₂, . . . , x_(n)}. Finally, the interaction representation ofword x_(g) in the {x₁, x₂, . . . , x_(n)} is represented as:

${r_{g} = {\sum\limits_{i = 1}^{n}\;{\lambda_{gi}h_{i}}}};$

it is able to enumerate all the words in a sentence and return to theinteraction representation sequence, i.e. {r₁, r₂, . . . , r_(n)}. Themax-pooling method refers to maximizing sampling in a specifieddimension, in other words, it obtains the maximum value of thedimension. Sentence embedding refers to sentence representation, whichrepresents the sentence as a low-dimensional and dense vector, which isconvenient for the computer to understand and calculate.

Apply max-pooling method to generate the final sentence embeddings s inthe sequence, s=max{r₁, r₂, . . . , r_(n)}, completing to define theglobal interaction representation. That is: enumerating all the words inthe {x₁, x₂, . . . , x_(n)}, obtaining the interaction representationsequence {r₁, r₂, . . . , r_(n)} of the {x₁, x₂, . . . , x_(n)},generating sentence embedding s=max{r₁, r₂, . . . , r_(n)}.

In order to obtain the local and global interaction between words, LIRand GIR are integrated to form a hybrid interaction representation HIR.The HIR first generates a hidden state sequence {h₁, h₂, . . . , h_(n)}corresponding to the word sequence {x₁, x₂, . . . , x_(n)} based on thesteps of LIR. Then, the HIR apply the process of GIR in the hidden statesequence to obtain the final sentence embeddings s.

In one embodiment, obtain the predicted label corresponding to thesentence embeddings s:ŝ=arg max p(

|s);

wherein ŝ∈

,

is the class label set; p(

|s)=softmax(W^((s))s+b^((s))); W^((s)) and b^((s)) are the reshapematrix and the bias term, respectively.

Set the loss function:

${L = {{{- \frac{1}{n}}{\sum\limits_{i = 1}^{n}\;{\log\;{p\left( {{\overset{\sim}{w}}_{i}❘h_{i}} \right)}}}} - {\log\;{p\left( {\overset{\sim}{s}❘s} \right)}}}};$

wherein h_(i) is the hidden state, {tilde over (w)}_(i) is the trueclass label of word x_(i), {tilde over (s)} is the true class label ofsentence embeddings s. Evaluate the quality of the sentence embeddings sbased on the loss function.

In the category prediction process, apply a sotfmax classifier to thesentence embedding to obtain a predicted label ŝ, wherein ŝ∈

,

is a class label set, i.e.:ŝ=arg max p(

|s).

andp(

|s)=softmax(W ^((s)) s+b ^((s)))

wherein W^((s)) and b^((s)) are the reshape matrix and the bias term,respectively. For the loss function in the formulated HIR, thecorresponding losses in LIR and GIR can be combined as follows:

${L = {{{- \frac{1}{n}}{\sum\limits_{i = 1}^{n}\;{\log\;{p\left( {{\overset{\sim}{w}}_{i}❘h_{i}} \right)}}}} - {\log\;{p\left( {\overset{\sim}{s}❘s} \right)}}}};$

wherein the former's loss derives from LIR and the latter's loss derivesfrom GIR. The h_(i) is the hidden state, while {tilde over (w)}_(i) isthe true class label of the word x_(i) in the LIR, {tilde over (s)} isthe true class label of the sentence embeddings s in the GIR.

In order to evaluate the quality of the proposed sentence embedding,consider an emotional classification task and try to answer thefollowing question; (RQ1) Can the sentence embedding model combined withthe interaction representation improve the performance of sentimentclassification? (RQ2) What is the effect of the length of the sentenceon performance?

Compare the performance of the methods provided by the embodiment withother recent recursive neural network based nested models. The followingbenchmark models can be used for comparison: (1) LSTM: A nested modelbased on long and short memory networks [6]. (2) Tree-LSTM: AnLSTM-based nested model that combines a parse tree. They are comparedwith the model corresponding to the sentence nesting method proposed bythe embodiment: (1) LIR (2.1), (2) GIR (2.2), and (3) HIR (2.3).

Use the Stanford Sentiment Treebank dataset sampled from the filmreview. The data set has five types of labels for each sentence: verynegative, negative, medium, positive, and very positive. In addition,the data set discards some medium sentences to divide the label into twocategories, negative and positive. This data set can be used as a2-class classification task or 5-class classification task. Table 1below details the statistical characteristics of this data set. Theaccuracy of use (at the sentence level) is recognized as the evaluationcriterion for the discussion model.

TABLE 1 Statistical characteristics of the data set Variable 5-classTask 2-class Task #Sentence 8544/1101/2210 6920/872/1821(train/dev/test) #Maximal sentence 56 56 length #Average sentence 19.3119.17 length #Vocabulary 21701 21701

For word embedding, the random initialization word embedding matrixW_(e), which will be learned during the training phase, setting the wordembedding dimension to 300. The fixed parameters are set as follows: thebatch size is set to 5, which is 5 sentences per batch; the hiddenvector dimension is set to 150; the loss rate is set to 0.5. Toinitialize the neural network, each matrix is initialized by a normalGaussian distribution and each bias term is initialized with a zerovector. In addition, the model was trained by using the AdaGradalgorithm with a learning rate of 0.05 and the entire training processwas set to 15 cycles.

In order to answer RQ1, in Table 2, the experimental results of thefive-class classification task and the two-class classification task ofall the discussion models are presented. Table 2 shows the accuracy onthe sentiment classification task. The best benchmark model and the bestperformance model in each column are underlined and bolded,respectively.

TABLE 2 Accuracy on sentiment classification tasks Model 5-class Task2-class Task LSTM .4223 .8085 Tree-LSTM .4548 .8483 LIR .4601 .8506 GIR.4609 .8529 HIR .4691 .8655

For the benchmark model, Tree-LSTM outperforms LSTM, achieving 7.67% and4.92% accuracy improvement on 5-class and 2-class classification tasks,which means that the grammatical structure is combined with theserialized nested model. Structured sentence embedding models do betterrepresent text for sentence classification. Models with interactionrepresentations, such as LIR, GIR, and HIR, are generally superior tobenchmark models. HIR is the best performing model in the proposedmodel. In the five-class classification task, HIR has a 3.15% accuracyimprovement for the best benchmark model Tree-LSTM, and a 1.96% and1.97% improvement for GIR and LIR, respectively. In the 2-classclassification task, compared with Tree-LSTM, GIR and LIR, the HIRreached 2.03%, 1.48% and 1.78% accuracy respectively. By characterizingthe local and global interactions between words, HIR can achieve bettersentence embedding, which is conducive to emotional classification.

GIR, like HIR, is also superior to Tree-LSTM, achieving a 1.35%improvement in 5-class classification task and a 0.54% improvement in2-class classification task. LIR performance is slightly worse than GIR,but still achieves 1.15% over 5-class task for Tree-LSTM and 0.27%accuracy for 2-class task. The difference between LIR and GIR can beexplained by the fact that LIR pays too much attention to theinteraction between local words, but not the global interaction of wordsin a sentence.

In order to answer RQ2, the sentences are manually divided into threegroups according to the length of the sentence, namely, short sentences(l∈(0,10)), medium sentences (l∈(10,20)) and long sentences (l∈(20,+∞)).The test results of 5-class classification task and 2-classclassification task are drawn on FIG. 2B and FIG. 2C, respectively.

For both classification tasks, it can be observed that as the length ofthe sentence increases, the performance of all of the models discusseddecreases monotonically. The longer the sentence, the more complex therelationship in the sentence, making it harder to get good sentenceembedding. For the benchmark model, Tree-LSTM is superior to LSTM foreach sentence length in five-class task. The method model proposed bythe embodiment generally has an advantage in each sentence in emotionalclassification. When the length of the sentence is short, medium andlong, HIR is 5.94%, 5.86%, and 3.10% higher than Tree-LSTM. This similarphenomenon can also be found in the comparison of LIR, GIR and baselinemodels. The advantages of characterizing interactions decrease as thelength of the sentence increases.

In 2-class task, the results similar to 5-class task were obtained.Compared to the results in FIG. 2B, HIR achieved a greater relativeimprovement over the baseline model in 5-class task: HIR increased by5.94%, 5.86% and 3.10% over Tree-LSTM in 5-class task when the length ofthe sentence is short, medium, and long, respectively; in 2-class task,there is an increase of 4.55%, 3.08% and 0% for the correspondingsentence length. Interestingly, Tree-LSTM managed to catch up with HIRin 2-class task when the sentence length was long.

As illustrated in FIG. 3, in one embodiment, it provides a textrepresentation device applied to sentence embedding 30, comprising: aword extraction module 31, a child word processing module 32, a parentword processing module 33, a hidden state processing module 34, asentence embedding processing module 35 and a quality evaluation module36.

A word extraction module 31 obtains a file to be processed, extracting asentence from the file; wherein the file includes a text file and awebpage file; obtaining n parent word corresponding to n words in thesentence. A child word processing module 32 determines the parent wordand the child words set C(p) corresponding to the parent word, settinghidden states h_(k) and memory cells c_(k) for each child words in theC(p), wherein k∈{1, 2, . . . ,|C(p)|}. A parent word processing module33 obtains a hidden interaction state {tilde over (h)}_(p) of the parentword based on a hidden interaction state of all child words in the C(p),inputting the {tilde over (h)}_(p) and the parent word into the LSTMcell to obtain the memory cells and hidden states of the parent word.

A hidden state processing module 34 obtains a sequence {x₁, x₂, . . . ,x_(n)} of parent word corresponding to n parent word as well as obtainsa hidden state sequence {h₁, h₂, . . . , h_(n)} corresponding to the{x₁, x₂, . . . , x_(n)} based on the hidden state of parent word. Asentence embedding processing module 35 obtains a interactionrepresentation sequence {r₁, r₂, . . . , r_(n)} of each parent words andother parent words in {x₁, x₂, . . . , x_(n)} based on the {h₁, h₂, . .. , h_(n)}, generating sentence embeddings based on the {r₁, r₂, . . . ,r_(n)}.

As illustrated in FIG. 4, the parent word processing module 33comprises: a hidden representation unit 331, a connective processingunit 332 and a hidden state extracting unit 333. A hidden representationunit 331 converts the parent word x_(p) into a hidden representationh_(p) =tanh(W^((h))x_(p)+b^(h)) wherein, W^((h)) and b^(h) are theweight matrix and the bias term, respectively. A connective processingunit 332 connects the k^(th) child words corresponding to the parentword x_(p) and the parent word x_(p), obtaining α_(k)=h_(p) W_(α)h_(k),wherein α_(k) is the connective representation of h_(p) and h_(k), W_(α)is a connective matrix. A hidden state extracting unit 333 calculatesthe word weight

$\lambda_{k} = \frac{\exp\left( \alpha_{k} \right)}{\sum_{i = 1}^{{C{(p)}}}{\exp\left( \alpha_{i} \right)}}$of the k^(th) child words of the parent word x_(p); obtaining a hiddeninteraction state

${\overset{\sim}{h}}_{p} = {\sum\limits_{i \in {C{(j)}}}\;{\lambda_{i}h_{i}}}$of the parent word x_(p); inputting the {tilde over (h)}_(p) and theparent word x_(p) into the LSTM cell to obtain the memory cells andhidden states of the parent word x_(p).

The hidden state extracting unit 333 uses the hidden interaction state{tilde over (h)}_(p) and the parent word x_(p) as the input to the LSTMcell to get:i _(p)=σ(U ^((i)) x _(p) +W ^((i)) {tilde over (h)} _(p) +b ^((i)));o _(p)=σ(U ^((o)) x _(p) +W ^((o)) {tilde over (h)} _(p) +b ^((o)));u _(p)=tanh(U ^((u)) x _(p) +W ^((u)) {tilde over (h)} _(p) +b ^((u)));f _(kp)=σ(U ^((f)) x _(p) +W ^((f)) h _(k) +b ^((f)));

wherein i_(p), o_(p) and f_(kp) are the input gate, output gate andforget gate, respectively; u_(p) is the candidate hidden state of x_(p);the corresponding weight matrix of x_(p) are U^((i)), U^((o)), U^((u))and U^((f)), the corresponding weight matrix of {tilde over (h)}_(p) orh_(k) are W^((i)), W^((o)), W^((u)) and W^((f)), the bias terms areb^((i)), b^((o)), b^((u)) and b^((f));

the hidden state extracting unit 333 obtains the memory cell of theparent word x_(p), the memory cell is represented as:

${c_{p} = {{i_{p} \odot u_{p}} + {\sum\limits_{k = 1}^{{C{(p)}}}\;{f_{kp} \odot c_{k}}}}};$

the hidden state extracting unit 333 obtains the hidden state of theparent word x_(p), the hidden state is represented as:h _(p) =o _(p)⊙ tanh(c _(p)).

The sentence embedding processing module 35 obtains the connectiverepresentation sequence {α_(g1), α_(g2), . . . , α_(gn)} between theword x_(g) in the {x₁, x₂, . . . , x_(n)} and other words; calculatingthe interaction weight of word x_(k) and word x_(g) in the {x₁, x₂, . .. , x_(n)}, get:

${\lambda_{g\; k} = \frac{\exp\left( \alpha_{g\; k} \right)}{\sum_{i = 1}^{n}{\exp\left( \alpha_{g\; i} \right)}}};$

the sentence embedding processing module 35 obtains the interactionrepresentation of x_(g) in {x₁, x₂, . . . , x_(n)}, which can berepresented as:

${r_{g} = {\sum\limits_{i = 1}^{n}\;{\lambda_{gi}h_{i}}}};$

the sentence embedding processing module 35 enumerates all the words inthe {x₁, x₂, . . . , x_(n)}, obtaining the interaction representationsequence {r₁, r₂, . . . , r_(n)} of the {x₁, x₂, . . . , x_(n)},generating the sentence embeddings s=max{r₁, r₂, . . . , r_(n)}.

The quality evaluation module 36 obtains the predicted labelcorresponding to the sentence embeddings s:ŝ=arg max p(

|s);

wherein ŝ∈

,

is the class label set; p(

|s)=softmax(W^((s))s+b^((s))); W^((s)) and b^((s)) are the reshapematrix and the bias term, respectively; the quality evaluation module 36sets the loss function:

${L = {{{- \frac{1}{n}}{\sum\limits_{i = 1}^{n}{\log\;{p\left( {{\overset{\sim}{w}}_{i}❘h_{i}} \right)}}}} - {\log\;{p\left( {\overset{\sim}{s}❘s} \right)}}}};$

wherein h_(i) is the hidden state, {tilde over (w)}_(i) is the trueclass label of word x_(i), {tilde over (s)} is the true class label ofsentence embeddings s; evaluating the quality of the sentence embeddingss based on the loss function.

In one embodiment, as shown in FIG. 5, it provides a text representationdevice applied to sentence embedding, comprising: a memorizer 51 and aprocessor 52; the memorizer 51 is configured to store instructions, theprocessor 52 is coupled to the memorizer 51; the processor 52 isconfigured to perform the aforementioned text representation methodapplied to sentence embedding based on instructions stored in thememorizer 51.

The memorizer 51 can be a high-speed RAM memorizer, a non-volatilememorizer and a memorizer array. The memorizer 51 can also bepartitioned and the blocks can be combined into a virtual volumeaccording to certain rules. The processor 52 can be a central processingunit (CPU), or an Application Specific Integrated Circuit (ASIC), or oneor more integrated circuits configured to implement the textrepresentation method applied to sentence embedding of the embodiment.

In one embodiment, the embodiment provides a computer readable storagemedium, storing computer program instructions, implements the steps ofthe aforementioned text representation method applied to sentenceembedding when the instructions are executed by the processor.

A device and text representation method applied to sentence embedding inthe above embodiment proposes to realize sentence embeddings through atwo-level interaction representation. The two-level interactionrepresentation is a local interaction representation (LIR) and a globalinteraction representation (GIR), respectively. The invention combinesthe two-level representation to generate a hybrid interactionrepresentation (HIR), which can improve the accuracy and efficiency ofsentence embeddings and be significantly better than the Tree-LSTM modelin terms of accuracy.

The methods and systems of the embodiments can be implemented in anumber of ways. For example, the methods and systems of the embodimentscan be implemented in software, hardware, firmware or the combinations.The aforementioned sequence of steps for the method is for illustrativepurposes only. The steps of the method of the embodiments are notlimited to the order specifically described above unless there arespecifically statement. Moreover, in some embodiments, they can also beembodied as a program recorded in a recording medium, the programcomprising machine readable instructions for implementing the methodaccording to the embodiment. Thus, the embodiment also covers arecording medium storing a program for performing the method accordingto the embodiment.

We claim:
 1. A text representation method applied to sentence embedding, executed by a processor, comprising: obtaining a file to be processed and extracting one or more sentences from the file; wherein the file comprises a text file or a webpage file; obtaining n parent words corresponding to the one or more sentences, wherein n is a number of the sentences; determining, for each parent word of the n parent words, a child words set C(p) corresponding to the parent word, setting hidden states h_(k) and memory cells c_(k) for each child word in the C(p), wherein k∈{1, 2, . . . , |C(p)|}, and |C(p)| is a number of child words in the C(p); obtaining a hidden interaction state {tilde over (h)}_(p) of each of the parent words based on a hidden interaction state of all child words in the C(p); inputting each of the {tilde over (h)}_(p) and the parent words into a Long-short term memory (LSTM) cell to obtain memory cells and hidden states of each of the parent words; obtaining a sequence of the parent words {x₁, x₂, . . . , x_(n)} corresponding to the n parent words and obtaining a hidden state sequence {h₁, h₂, . . . , h_(n)} corresponding to the {x₁, x₂, . . . , x_(n)} based on the hidden state of each parent word of the n parent words; and obtaining an interaction representation sequence {r₁, r₂, . . . , r_(n)} of each parent word in the {x₁, x₂, . . . , x_(n)} based on {h₁, h₂, . . . , h_(n)}; and generating sentence embeddings s based on the {r₁, r₂, . . . , r_(n)}, wherein the obtaining the hidden interaction state {tilde over (h)}_(p) comprises: converting each parent word x_(p) into a hidden representation h_(p) =tanh(W^((h))x_(p)+b^(h)); wherein W^((h)) is a weight matrix and b^(h) is a bias term; connecting each parent word x_(p) and each child word in the corresponding child word set C(p), obtaining α_(k)=h_(p) W_(α)h_(k), wherein α_(k) is a connective representation of both h_(p) and the hidden state h_(k), W_(α) is a connective matrix to be learned, and k is a number of the child words in the corresponding child word set C(p); calculating a word weight $\lambda_{k} = \frac{\exp\left( \alpha_{k} \right)}{\sum_{i = 1}^{{C{(p)}}}{\exp\left( \alpha_{i} \right)}}$ of each child word in the corresponding child word set C(p); and obtaining, for each parent word x_(p), the hidden interaction state ${\overset{\sim}{h}}_{p} = {\sum\limits_{i \in {C{(j)}}}\;{\lambda_{i}h_{i}}}$ that relates to all child states of the parent word x_(p); wherein the text representation method is applied to an emotional classification task to achieve emotional classification of the one or more sentences with enhanced accuracy.
 2. The text representation method of claim 1, wherein the inputting comprises: inputting each parent word x_(p) and each hidden interaction state {tilde over (h)}_(p) corresponding to each parent word x_(p) into the LSTM cell to obtain: i _(p)=σ(U ^((i)) x _(p) +W ^((i)) {tilde over (h)} _(p) +b ^((i))); o _(p)=σ(U ^((o)) x _(p) +W ^((o)) {tilde over (h)} _(p) +b ^((o))); u _(p)=tanh(U ^((u)) x _(p) +W ^((u)) {tilde over (h)} _(p) +b ^((u))); f _(kp)=σ(U ^((f)) x _(p) +W ^((f)) h _(k) +b ^((f))); wherein i_(p) is an input gate, o_(p) is an output gate, f_(kp) is a forget gate, u_(p) is a candidate hidden state of x_(p), U^((i)), U_((o)), U^((u)) and U^((f)) are corresponding weight matrices of x_(p), W^((i)), W^((o)), W^((u)) and W^((f)) are corresponding weight matrices of {tilde over (h)}_(p), and b^((i)), b^((o)), b^((u)) and b^((f)) are bias terms; obtaining a memory cell c_(p) of each parent word x_(p), wherein the memory cell c_(p) is represented as: ${c_{p} = {{i_{p} \odot u_{p}} + {\sum\limits_{k = 1}^{{C{(p)}}}\;{f_{kp} \odot c_{k}}}}};$ and obtaining a hidden state h_(p) of the parent word x_(p), wherein the hidden state h_(p) is represented as: h _(p) =o _(p)⊙ tanh(c _(p)).
 3. The text representation method of claim 2, wherein the generating sentence embeddings based on the {r₁, r₂, . . . , r_(n)} comprises: obtaining, for each of the parent words in the {x₁, x₂, . . . , x_(n)}, a connective representation sequence {α_(g1), α_(g2), . . . , α_(gn)} between each reference parent word x_(g) in the {x₁, x₂, . . . , x_(n)} and other parent words x_(k) in the {x₁, x₂, . . . , x_(n)}; calculating an interaction weight λ_(gk) of each of the other parent words x_(k) and each reference parent word x_(g) in the {x₁, x₂, . . . , x_(n)} according to: ${\lambda_{g\; k} = \frac{\exp\left( \alpha_{g\; k} \right)}{\sum_{i = 1}^{n}{\exp\left( \alpha_{g\; i} \right)}}};$ obtaining an interaction representation r_(g) for each reference parent word x_(g) in {x₁, x₂, . . . , x_(n)} according to: ${r_{g} = {\sum\limits_{i = 1}^{n}\;{\lambda_{gi}h_{i}}}};$ obtaining the interaction representation sequence {r₁, r₂, . . . , r_(n)} for each of the parent words in the {x₁, x₂, . . . , x_(n)},and generating, for each of the parent words in the {x₁, x₂, . . . , x_(n)} the sentence embeddings s according to s=max{r₁, r₂, . . . , r_(n)}.
 4. The text representation method of claim 3, further comprising: obtaining a predicted label ŝ corresponding to the sentence embeddings s: ŝ=arg max p(

|s); wherein ŝ∈

,

is a class label set; p(

|s)=softmax(W^((s))s+b^((s))); W^((s)) is a reshape matrix, and b^((s)) is a bias term; setting a loss function L according to: ${L = {{{- \frac{1}{n}}{\sum\limits_{i = 1}^{n}{\log\;{p\left( {{\overset{\sim}{w}}_{i}❘h_{i}} \right)}}}} - {\log\;{p\left( {\overset{\sim}{s}❘s} \right)}}}};$ wherein h_(i) is a hidden state, {tilde over (w)}_(i) is a true class label of a parent word x_(i), {tilde over (s)} is a true class label of the sentence embeddings s; and evaluating a quality of the sentence embeddings s based on the loss function L.
 5. A text representation device applied to sentence embedding comprising: a word extraction module, configured to obtain a file to be processed and extract one or more sentences from the file; wherein the file comprises: a text file or a webpage file; and obtain n parent words corresponding to the one or more sentences, wherein n is a number of the sentences; a child word processing module, configured to determine, for each parent word of the n parent words, a child word set C(p) corresponding to the parent word, setting hidden states h_(k) and memory cells c_(k) for each child word in the C(p), wherein k∈{1, 2, . . . ,|C(p)|} and |C(p)| is a number of child words in the C(p); a parent word processing module, configured to obtain hidden interaction states {tilde over (h)}_(p) of each of the parent words based on the hidden interaction states of all child words in the C(p); inputting each of the {tilde over (h)}_(p) and the parent words into a Long-short term memory (LSTM) cell to obtain the memory cells and hidden states of each of the parent words; a hidden state processing module, configured to obtain a sequence {x₁, x₂, . . . , x_(n)} of parent words corresponding to n parent words and obtain a hidden state sequence {h₁, h₂, . . . , h_(n)} corresponding to the {x₁, x₂, . . . , x_(n)} based on the hidden state of each parent word of the n parent words; and a sentence embedding processing module, configured to obtain an interaction representation sequence {r₁, r₂, . . . , r_(n)} of each parent word in the {x₁, x₂, . . . , x_(n)} based on the {h₁, h₂, . . . , h_(n)}, and generating sentence embeddings s based on the {r₁, r₂, . . . , r_(n)}; wherein the parent word processing module further comprises: a hidden representation unit, configured to convert each parent word x_(p) into a hidden representation h_(p) =tanh(W^((h))x_(p)+b^(h)); wherein, W^((h)) and b^(h) is a weight matrix and b^(h) is a bias term; a connective processing unit, configured to connect each child word in the corresponding child word set C(p) and each parent word x_(p), obtaining α_(k)=h_(p) W_(α)h_(k), wherein α_(k) is the connective representation of h_(p) and h_(k), W_(α) is a connective matrix and k is a number of the child words in the corresponding child word set C(p); and a hidden state extracting unit, configured to calculate a word weight $\lambda_{k} = \frac{\exp\left( \alpha_{k} \right)}{\sum_{i = 1}^{{C{(p)}}}{\exp\left( \alpha_{i} \right)}}$ of each child word in the corresponding child word set C(p); obtaining, for each parent word x_(p), the hidden interaction state ${{\overset{\sim}{h}}_{p} = {\sum\limits_{i \in {C{(j)}}}\;{\lambda_{i}h_{i}}}};$ wherein the text representation method is applied to an emotional classification task to achieve emotional classification of the one or more sentences with enhanced accuracy.
 6. A text representation device of claim 5, wherein: the hidden state processing module is configured to input each parent word x_(p) and the hidden interaction state {tilde over (h)}_(p) corresponding to each parent word x_(p) into the LSTM cell to obtain: i _(p)=σ(U ^((i)) x _(p) +W ^((i)) {tilde over (h)} _(p) +b ^((i))); o _(p)=σ(U ^((o)) x _(p) +W ^((o)) {tilde over (h)} _(p) +b ^((o))); u _(p)=tanh(U ^((u)) x _(p) +W ^((u)) {tilde over (h)} _(p) +b ^((u))); f _(kp)=σ(U ^((f)) x _(p) +W ^((f)) h _(k) +b ^((f))); wherein i_(p) is an input gate, o_(p) is an output gate, f_(kp) is a forget gate, u_(p) is a candidate hidden state of x_(p), U^((i)), U^((o)), U^((u)) and U^((f)) are corresponding weight matrices of x_(p), W^((i)), W^((o)), W^((u)) and W^((f)) are corresponding weight matrices of {tilde over (h)}_(p), and b^((i)), b^((o)), b^((u)) and b^((f)) are bias terms; the hidden state processing module is configured to obtain a memory cell c_(p) of each parent word x_(p), wherein the memory cell c_(p) is represented as: ${c_{p} = {{i_{p} \odot u_{p}} + {\sum\limits_{k = 1}^{{C{(p)}}}\;{f_{kp} \odot c_{k}}}}};$ and the hidden state processing module is configured to obtain a hidden state h_(p) of each parent word x_(p), the hidden state h_(p) is represented as: h _(p) =o _(p)⊙ tanh(c _(p)). 